<?php
/**
 * chaotian
 * User: 申龙彪
 * Date: 2024-02-25
 * Time: 15:55
 */

namespace app\common\command;

use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;

class Order extends Command
{
    protected function configure()
    {
        $this->setName('order')->setDescription('已发货订单处理');
    }

    protected function execute(Input $input, Output $output)
    {
        Db::name('activity_order')->where([
            'status' => 2,
            'pay_time' => ['<', time() - 60 * 60 * 24 * 7]
        ])->chunk(100, function ($list) {
            foreach ($list as $v) {
                Db::name('activity_order')->where('id', $v['id'])->update(['status' => 3]);
            }
        });
    }
}
